package com.leetcode.partition20;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/22 14:35
 */
public class LC1994好子集的数目 {

    private static final int mod = 1000000007;
    private static final int[] primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};
    private static long[] f = new long[1 << 10];
    private static int[] cnt = new int[31];
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int[] nums = new int[ss.length];
        for (int i = 0; i < ss.length; i++) nums[i] = Integer.parseInt(ss[i]);
        writer.write(numberOfGoodSubsets(nums) + "\n");
        writer.flush();
    }

    public static int numberOfGoodSubsets(int[] nums) {
        n = nums.length;
        for (int num : nums) cnt[num]++;
        f[0] = 1;
        for (int i = 2; i <= 30; i++) {
            //如果当前数不存在或者其因子包含一个完全平方数，就跳过
            if (cnt[i] == 0 || i % 4 == 0 || i % 9 == 0 || i % 25 == 0) continue;
            int cur = 0;
            for (int j = 0; j < 10; j++) {
                if (i % primes[j] == 0) cur |= 1 << j;
            }
            for (int pre = 0; pre < 1 << 10; pre++) {
                if ((pre & cur) != 0) continue;
                f[pre | cur] = (f[pre | cur] + cnt[i] * f[pre] % mod) % mod;
            }
        }
        long ans = 0;
        for (int i = 1; i < 1 << 10; i++) ans = (ans + f[i]) % mod;
        //考虑1的情况
        for (int i = 0; i < cnt[1]; i++) ans = (ans * 2) % mod;
        return (int) ans;
    }

    private static boolean check(int num) {
        int res = (int) Math.sqrt(num);
        return res * res == num;
    }
}
